<?php

namespace app\services\ad\monitor;

use app\caches\AdMediaDockingCache;
use app\services\ServiceBase;
use support\Request;

class MonitorBase extends ServiceBase
{
    protected $mediaId = 0; // 媒体id
    protected $mediaDockingId = 0; // 对接id

    public function __construct($media_id, $media_docking_id)
    {
        parent::__construct();
        $this->mediaId        = $media_id;
        $this->mediaDockingId = $media_docking_id;
    }

    public static function getClass($media_docking_id)
    {
        $docking = AdMediaDockingCache::getInstance()->remember($media_docking_id);
        $class_name = "\\app\\services\\ad\\monitor\\{$docking['class']}";
        if (!class_exists($class_name)) {
            return self::getInstance($docking['media_id'], $media_docking_id);
        }

        return $class_name::getInstance($docking['media_id'], $media_docking_id);
    }

    // 此接口由子类继承
    // 处理落地监控数据
    public function handleMonitorInfo(Request $request)
    {
        return true;
    }
}
